/**
 * 
 */
package smallChanges.statements;

import smallChanges.Tokenization.TokenSet;

/**
 * @author jspacco
 *
 */
public class FieldDeclarationStatement extends SingleStatement implements IAccessNode
{
    private SCVisibility visibility;
    private SCModifiers modifiers;
    private String name;
    // SCType is a candidate for meta-information
    private SCType type;
    
    public String getName() {
		return name;
	}
    
	public void setName(String name) {
		this.name = name;
	}

	public FieldDeclarationStatement(TokenSet tokenSet) {
        super(tokenSet);
    }

    public SCVisibility getVisibility()
    {
        return visibility;
    }

    public void setVisibility(SCVisibility visibility)
    {
        this.visibility = visibility;
    }

    public SCModifiers getModifiers()
    {
        return modifiers;
    }

    public SCType getType() {
        return type;
    }

    /* only for FAKE FieldDeclarationStatement pulled from DB */
    public void setTypeAsString(String type)
    {
    	this.type = new SCType(this.getTokensInRange());
    	this.type.setType(type);
    }
    
    public String getTypeAsString()
    {
    	return type.getType();
    }
    
    public void setType(SCType type) {
        this.type = type;
        // add the tokens used to define the type
        // to the tokens used to define this field
        // XXX This creates potentially over-lapping token sets
        // as well as multi-token ranges with gaps
        // for example: "int x=10, y=20;"
        // the "int" token is the type for both field declarations,
        // while the , and ; are not part of either field declaration
        tokensInRange.merge(type);
        setBeginLine(type.getBeginLine());
        setBeginColumn(type.getBeginColumn());
    }

    public void setModifiers(SCModifiers modifiers)
    {
        this.modifiers = modifiers;
    }

}
